#ifndef __HIKARI_UTILS__
#define __HIKARI_UTILS__

#include <clocale>
#include <locale>
#include <string>
#include <vector>

#if defined(_MSC_VER)
#  define NOMINMAX // workaround a bug in windows.h
#  include <windows.h>
#else
#  include <sys/time.h>
#endif


class Utils{
public:
	static std::string wstring_to_string(const std::wstring& text);
	static std::wstring string_to_wstring(std::string& text);
	static bool equal(std::wstring&str1,std::wstring&str2);
	static bool equal(std::wstring&str1, const wchar_t*str2);
	static bool isEmpty(std::wstring&string);
	static long hash_WString(const std::wstring&s);
	static long hash_WString(const wchar_t*string);
	static int lastIndexOf(std::wstring&string, wchar_t symbol);
	static std::wstring replaceWString(std::wstring&string, wchar_t toFind, wchar_t toReplace);
	static std::wstring getFileExtension(std::wstring&path);
	static std::wstring getFilePath(std::wstring&path);
	static std::wstring getFileWithExtension(std::wstring&path);
	static std::wstring getFileNameWithoutExtension(std::wstring&path);
	static void errorLog(std::wstring&message);
	static void errorLog(const wchar_t*message);
	static std::wstring wstring(int value);
	static long long doubleHash(double value);
	/*static btVector3 vectorToBtVector(const irr::core::vector3df&vector);
	static irr::core::vector3df btVectorToVector(const btVector3&vector);*/
};

class CTimer{
   private:
#     if defined(_MSC_VER)
         LARGE_INTEGER m_depart;
#     else
         timeval m_depart;
#     endif

   public:
      inline void start()
      {
#        if defined(_MSC_VER)
            QueryPerformanceCounter(&m_depart);
#        else
            gettimeofday(&m_depart, 0);
#        endif
      };

	  inline void updateDepart(){
#		 if defined(_MSC_VER)
            QueryPerformanceCounter(&m_depart);
#        else
            gettimeofday(&m_depart, 0);
#        endif
	  }

      inline float GetSecondes() const
      {
#        if defined(_MSC_VER)
            LARGE_INTEGER now;
            LARGE_INTEGER freq;

            QueryPerformanceCounter(&now);
            QueryPerformanceFrequency(&freq);

            return (now.QuadPart - m_depart.QuadPart) / static_cast<float>(freq.QuadPart);
#        else
            timeval now;
            gettimeofday(&now, 0);

            return now.tv_sec - m_depart.tv_sec + (now.tv_usec - m_depart.tv_usec) / 1000000.0f;
#        endif
      };
 };

#endif